<html>
<head><meta charset="utf-8"><title>documenting concrete consts in types · project-const-generics · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/index.html">project-const-generics</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html">documenting concrete consts in types</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="216207602"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216207602" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216207602">(Nov 10 2020 at 13:03)</a>:</h4>
<p>When documenting const generics, we explicitly mention the type of concrete const args outside of arrays. For example<br>
<code>impl Trait&lt;13&gt; for [u8; 13]</code> is documented as <code>impl Trait&lt;13_usize&gt; for [u8; 13]</code>.</p>



<a name="216207695"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216207695" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216207695">(Nov 10 2020 at 13:04)</a>:</h4>
<p>I personally don't have a preference here. It is a bit verbose, but it can be helpful to read <code>Foo&lt;3_u8, 16_usize&gt;</code> instead of just <code>Foo&lt;3, 16&gt;</code>.</p>



<a name="216208076"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216208076" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216208076">(Nov 10 2020 at 13:07)</a>:</h4>
<p>In case you prefer to either keep or remove these type annotations, this is your chance to influence the future of the rust programming language <span aria-label="fire" class="emoji emoji-1f525" role="img" title="fire">:fire:</span></p>



<a name="216208169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216208169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> jplatte <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216208169">(Nov 10 2020 at 13:08)</a>:</h4>
<p>I have a hard time coming up with a realistic example for where the suffix would be useful. It's never ambiguous for a specific type, and even if in the future types like <code>Foo&lt;T, const C: T&gt;</code> are allowed, rendering <code>Foo&lt;usize, 1_usize&gt;</code> would be pointless.</p>



<a name="216208436"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216208436" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> jplatte <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216208436">(Nov 10 2020 at 13:10)</a>:</h4>
<p>I guess it could theoretically be hard to tell the actual type in complex situations, but not with anything like the current feature set. I.e. it seems feasible that if <code>Foo&lt;T, const C: T&gt;</code> will at some point be allowed, <code>Foo&lt;T: Trait, const C: T::Assoc&gt;</code> will too (but what would you even use that for?)</p>



<a name="216208530"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216208530" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216208530">(Nov 10 2020 at 13:11)</a>:</h4>
<p>I would rather rustdoc just normalizes that at the <em>trait</em> definition</p>



<a name="216208544"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216208544" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216208544">(Nov 10 2020 at 13:11)</a>:</h4>
<p>I was thinking about <code>struct EncryptionStuff&lt;const BLOCKS: u8, const BLOCK_SIZE: usize, const PASS_COUNT: u32&gt;</code></p>



<a name="216208551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216208551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216208551">(Nov 10 2020 at 13:11)</a>:</h4>
<p>oh well I guess you can't since you don't know <code>T</code> yet</p>



<a name="216208633"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216208633" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216208633">(Nov 10 2020 at 13:12)</a>:</h4>
<p>where the type of the const parameters can be helpful to remember the expected order</p>



<a name="216208743"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216208743" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> jplatte <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216208743">(Nov 10 2020 at 13:13)</a>:</h4>
<p>I think things like the <code>EncryptionStuff</code> example should eventually just become parametrized over a struct, although there will of course be a timespan in which primitive const generics will be supported without custom types being supported.</p>



<a name="216208794"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216208794" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216208794">(Nov 10 2020 at 13:14)</a>:</h4>
<p><span aria-label="shrug" class="emoji emoji-1f937" role="img" title="shrug">:shrug:</span> this seems like enough of an edge case I don't think it's worth making the rest of the docs more noisy</p>



<a name="216209062"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216209062" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> jplatte <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216209062">(Nov 10 2020 at 13:16)</a>:</h4>
<p>Compiler errors will also just be annoying without that, a type mismatch between <code>EncryptionStuff&lt;4, 128, 2&gt;</code> and <code>EncryptionStuff&lt;4, 128, 3&gt;</code> is much harder to understand than a mismatch between <code>EncryptionStuff&lt;EncryptionParams { blocks: 4, block_size: 128, pass_count: 2 }&gt;</code> and <code>EncryptionStuff&lt;EncryptionParams { blocks: 4, block_size: 128, pass_count: 3 }&gt;</code></p>



<a name="216217894"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216217894" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216217894">(Nov 10 2020 at 14:23)</a>:</h4>
<p>For that example, I think the former is more understandable, because of how it would likely be formatted:</p>
<div class="codehilite"><pre><span></span><code>expected: EncryptionStuff&lt;4, 128, 2&gt;
found:    EncryptionStuff&lt;4, 128, 3&gt;
</code></pre></div>



<a name="216218048"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216218048" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216218048">(Nov 10 2020 at 14:24)</a>:</h4>
<p>Where I'd worry would be</p>
<div class="codehilite"><pre><span></span><code>expected: EncryptionStuff&lt;4, 128, 2&gt;
found:    EncryptionStuff&lt;4, 128, 2&gt;
</code></pre></div>
<p>Which should be</p>
<div class="codehilite"><pre><span></span><code>expected: EncryptionStuff&lt;4, 128, 2u8&gt;
found:    EncryptionStuff&lt;4, 128, 2u16&gt;
</code></pre></div>



<a name="216218236"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216218236" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216218236">(Nov 10 2020 at 14:25)</a>:</h4>
<p>I'd look to the recent work to help remove the full path from error text when it's unambiguous. The error messages should strive to highlight the differences as much as possible.</p>



<a name="216221549"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216221549" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216221549">(Nov 10 2020 at 14:46)</a>:</h4>
<p>what about making the type alt text when you hover over the value?</p>



<a name="216222149"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216222149" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216222149">(Nov 10 2020 at 14:51)</a>:</h4>
<p>Similar, but maybe more accessible, would be to add expando-text:</p>
<p><a href="/user_uploads/4715/6QuxfVBuph3-85IAZBnRMNQu/image.png">image.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/6QuxfVBuph3-85IAZBnRMNQu/image.png" title="image.png"><img src="/user_uploads/4715/6QuxfVBuph3-85IAZBnRMNQu/image.png"></a></div>



<a name="216222735"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216222735" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216222735">(Nov 10 2020 at 14:54)</a>:</h4>
<p>Please no more buttons, rustdoc has enough buttons <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="216222739"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216222739" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216222739">(Nov 10 2020 at 14:54)</a>:</h4>
<p>Title text sounds fine though</p>



<a name="216222821"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216222821" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216222821">(Nov 10 2020 at 14:55)</a>:</h4>
<p>Ideally this would always use the way it was written in the source code, except when it's an expression that can be simplified</p>



<a name="216222905"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216222905" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216222905">(Nov 10 2020 at 14:55)</a>:</h4>
<p>That's it works for associated types, both <code>T::Item</code> and <code>&lt;T as Trait&gt;::Item</code> are rendered as written</p>



<a name="216223144"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216223144" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216223144">(Nov 10 2020 at 14:57)</a>:</h4>
<p>so</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">const</span><span class="w"> </span><span class="n">SIZE</span>: <span class="kt">u8</span> <span class="o">=</span><span class="w"> </span><span class="mi">42</span><span class="p">;</span><span class="w"></span>
<span class="k">impl</span><span class="w"> </span><span class="n">Foo</span><span class="o">&lt;</span><span class="n">SIZE</span><span class="o">&gt;</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Bar</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
</code></pre></div>
<p>would say <code>SIZE</code> literally (and ideally link to <code>SIZE</code>, given visibility)?</p>



<a name="216224921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216224921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> jplatte <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216224921">(Nov 10 2020 at 15:09)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116155">Jake Goulding</span> <a href="#narrow/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types/near/216218048">said</a>:</p>
<blockquote>
<p>Where I'd worry would be</p>
<div class="codehilite"><pre><span></span><code>expected: EncryptionStuff&lt;4, 128, 2&gt;
found:    EncryptionStuff&lt;4, 128, 2&gt;
</code></pre></div>
<p>Which should be</p>
<div class="codehilite"><pre><span></span><code>expected: EncryptionStuff&lt;4, 128, 2u8&gt;
found:    EncryptionStuff&lt;4, 128, 2u16&gt;
</code></pre></div>
</blockquote>
<p>This can't happen though, right? You would already get an error trying to instantiate one of the two since the type of the third const parameter cannot be generic.</p>



<a name="216225889"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216225889" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216225889">(Nov 10 2020 at 15:17)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116155">Jake Goulding</span> <a href="#narrow/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types/near/216223144">said</a>:</p>
<blockquote>
<p>so</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">const</span><span class="w"> </span><span class="n">SIZE</span>: <span class="kt">u8</span> <span class="o">=</span><span class="w"> </span><span class="mi">42</span><span class="p">;</span><span class="w"></span>
<span class="k">impl</span><span class="w"> </span><span class="n">Foo</span><span class="o">&lt;</span><span class="n">SIZE</span><span class="o">&gt;</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Bar</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
</code></pre></div>
<p>would say <code>SIZE</code> literally (and ideally link to <code>SIZE</code>, given visibility)?</p>
</blockquote>
<p>yes: <a href="/user_uploads/4715/ARSPkWp031JoVUUIo7mB9S_I/image.png">image.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/ARSPkWp031JoVUUIo7mB9S_I/image.png" title="image.png"><img src="/user_uploads/4715/ARSPkWp031JoVUUIo7mB9S_I/image.png"></a></div>



<a name="216225915"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216225915" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216225915">(Nov 10 2020 at 15:17)</a>:</h4>
<p>apparently it doesn't link though, we could fix that</p>



<a name="216226561"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216226561" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216226561">(Nov 10 2020 at 15:22)</a>:</h4>
<p>What about</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">impl</span><span class="w"> </span><span class="n">Foo</span><span class="o">&lt;</span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">b</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="n">a</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mi">10</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">b</span><span class="w"></span>
<span class="p">}</span><span class="o">&gt;</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Bar</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
</code></pre></div>



<a name="216226604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216226604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216226604">(Nov 10 2020 at 15:22)</a>:</h4>
<p><del>this is why playground should have rustdoc support</del></p>



<a name="216226621"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216226621" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216226621">(Nov 10 2020 at 15:22)</a>:</h4>
<p>(I assume arbitrary const expressions are valid there)</p>



<a name="216226678"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216226678" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216226678">(Nov 10 2020 at 15:23)</a>:</h4>
<p>well look at that<br>
<a href="/user_uploads/4715/Iinrux22Q-8LvqTUmB2wNbMF/image.png">image.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/Iinrux22Q-8LvqTUmB2wNbMF/image.png" title="image.png"><img src="/user_uploads/4715/Iinrux22Q-8LvqTUmB2wNbMF/image.png"></a></div>



<a name="216226693"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216226693" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216226693">(Nov 10 2020 at 15:23)</a>:</h4>
<p><a href="https://github.com/integer32llc/rust-playground/issues/489">you know</a></p>



<a name="216226738"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216226738" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216226738">(Nov 10 2020 at 15:23)</a>:</h4>
<p>one of these days I'll get around to it</p>



<a name="216226803"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216226803" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216226803">(Nov 10 2020 at 15:24)</a>:</h4>
<p><span class="user-mention" data-user-id="210267">@Nemo157</span> has been working on <a href="https://github.com/Nemo157/oubliette/">https://github.com/Nemo157/oubliette/</a> to allow rendering the doc client-side</p>



<a name="216226825"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216226825" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216226825">(Nov 10 2020 at 15:24)</a>:</h4>
<p>then you wouldn't even need to store them, just pack them in an archive and send it to the browser</p>



<a name="216227061"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216227061" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216227061">(Nov 10 2020 at 15:26)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="cp">#![feature(min_const_generics)]</span><span class="w"></span>

<span class="k">struct</span> <span class="nc">EncryptionStuff</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">A</span>: <span class="kt">u8</span><span class="p">,</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">B</span>: <span class="kt">u8</span><span class="p">,</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">C</span>: <span class="kt">u8</span><span class="o">&gt;</span><span class="p">;</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">demo</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">Z</span>: <span class="kt">u16</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="nc">EncryptionStuff</span><span class="o">&lt;</span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="n">Z</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">EncryptionStuff</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<div class="codehilite"><pre><span></span><code>error[E0308]: mismatched types
 --&gt; src/lib.rs:5:50
  |
5 | fn demo&lt;const Z: u16&gt;() -&gt; EncryptionStuff&lt;1, 2, Z&gt; {
  |                                                  ^ expected `u8`, found `u16`
</code></pre></div>
<p>That error seems reasonable already</p>



<a name="216227203"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216227203" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216227203">(Nov 10 2020 at 15:27)</a>:</h4>
<p>And in rustdoc, you should be able to click on the return type to then see that it has a <code>const u8</code> parameter. So maybe it doesn't need to be  at the usage site.</p>



<a name="216227224"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216227224" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216227224">(Nov 10 2020 at 15:27)</a>:</h4>
<p>Just like we don't list trait bounds at the usage site.</p>



<a name="216227322"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216227322" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216227322">(Nov 10 2020 at 15:28)</a>:</h4>
<p>right, yeah I guess my main objection is 'why are primitives special'</p>



<a name="216227328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216227328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216227328">(Nov 10 2020 at 15:28)</a>:</h4>
<p>e.g. </p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">struct</span> <span class="nc">EncryptionStuff</span><span class="o">&lt;</span><span class="n">A</span>: <span class="nb">Copy</span><span class="o">&gt;</span><span class="p">(</span><span class="n">A</span><span class="p">);</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">demo</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="nc">EncryptionStuff</span><span class="o">&lt;</span><span class="kt">u8</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">EncryptionStuff</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="216278412"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216278412" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216278412">(Nov 10 2020 at 21:38)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> <a href="#narrow/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types/near/216226678">said</a>:</p>
<blockquote>
<p>well look at that<br>
<a href="/user_uploads/4715/Iinrux22Q-8LvqTUmB2wNbMF/image.png">image.png</a></p>
</blockquote>
<p>so we are evaluating some constants in rust doc and do not evaluate some other consts?</p>



<a name="216278463"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216278463" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216278463">(Nov 10 2020 at 21:39)</a>:</h4>
<p>that's concerning, esp because to my knowledge we don't have any tests which do not evaluate here</p>



<a name="216278599"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216278599" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216278599">(Nov 10 2020 at 21:40)</a>:</h4>
<p>looks like this is something I have to look into during the next few weeks</p>



<a name="216278678"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216278678" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216278678">(Nov 10 2020 at 21:41)</a>:</h4>
<p><span class="user-mention" data-user-id="116155">@Jake Goulding</span> you're catching all the bugs :P</p>



<a name="216278820"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216278820" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216278820">(Nov 10 2020 at 21:42)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types/near/216278412">said</a>:</p>
<blockquote>
<p>so we are evaluating some constants in rust doc and do not evaluate some other consts?</p>
</blockquote>
<p>Are you sure? It could be evaluated still, but rustdoc <em>chooses</em> to show the original source, perhaps?</p>



<a name="216278873"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216278873" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216278873">(Nov 10 2020 at 21:43)</a>:</h4>
<p>I don't think so, notice how it has different formatting from the original</p>



<a name="216278879"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216278879" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216278879">(Nov 10 2020 at 21:43)</a>:</h4>
<p>well it can be evaluated, but rustdoc shows the unevaluated constant</p>



<a name="216278896"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216278896" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216278896">(Nov 10 2020 at 21:43)</a>:</h4>
<p>how it does so is secondary to me rn <span aria-label="laughter tears" class="emoji emoji-1f602" role="img" title="laughter tears">:laughter_tears:</span></p>



<a name="216278919"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216278919" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216278919">(Nov 10 2020 at 21:43)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> <a href="#narrow/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types/near/216278873">said</a>:</p>
<blockquote>
<p>I don't think so, notice how it has different formatting from the original</p>
</blockquote>
<p>Wouldn't that just be a missing <code>pre</code> tag?</p>



<a name="216278980"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216278980" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216278980">(Nov 10 2020 at 21:44)</a>:</h4>
<p>I mean, definitely look into it to be sure.</p>



<a name="216278997"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216278997" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216278997">(Nov 10 2020 at 21:44)</a>:</h4>
<p>I just can see a path where you are both correct and there is no problem.</p>



<a name="216279127"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216279127" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216279127">(Nov 10 2020 at 21:46)</a>:</h4>
<p>yeah, even if we are just showing the original source this is still something we don't have a test for yet afaik</p>



<a name="216394742"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/documenting%20concrete%20consts%20in%20types/near/216394742" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/documenting.20concrete.20consts.20in.20types.html#216394742">(Nov 11 2020 at 20:26)</a>:</h4>
<p>ok, so it looks good enough to me <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span> considering that the rustdoc output isn't part of our stability guarantees I am fine with it not being perfect in all cases. Added one testwith an unevaluated consts</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>